﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FTradeReceivablesChangeHeTong.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.FTradeModel.FTradeReceivablesChangeHeTong" %>
<%--变更合同条款--%>
<script type="text/javascript">

    $(document).ready(function () {

//        $("#FTradeReceivablesChangeAgent_Price,#FTradeReceivablesChangeAgent_GPSFeiYong,#FTradeReceivablesChangeAgent_YueCuXiaoJinE").change(function () {
//            changeHHeTongJinE()
//        })
//        function changeHHeTongJinE() {
//            //处理合同金额
//            if ($(this).val() == "")
//                $(this).val(0);
//            var Price = parseFloat($("#FTradeReceivablesChangeAgent_Price").val());
//            var GPSFeiYong = parseFloat($("#FTradeReceivablesChangeAgent_GPSFeiYong").val());
//            var YueCuXiaoJinE = parseFloat($("#FTradeReceivablesChangeAgent_YueCuXiaoJinE").val());

//            $("#FTradeReceivablesChangeAgent_HeTongJinE").val((-1) * Price + GPSFeiYong + YueCuXiaoJinE);
//        }
//        $("#FTradeReceivablesChangeAgent_GPSFeiYong").val((-1) * parseFloat($("#FTradeReceivablesChangeAgent_GPSFeiYong").val()));
//        $("#FTradeReceivablesChangeAgent_YueCuXiaoJinE").val((-1) * parseFloat($("#FTradeReceivablesChangeAgent_YueCuXiaoJinE").val()))

//        changeHHeTongJinE();

//        //2.处理换新机后的信息
//        //处理合同金额
//        $("#FTradeReceivablesChangeAgentNew_Price,#FTradeReceivablesChangeAgentNew_GPSFeiYong,#FTradeReceivablesChangeAgentNew_YueCuXiaoJinE").change(function () {
//            if ($(this).val() == "")
//                $(this).val(0);
//            var Price = parseFloat($("#FTradeReceivablesChangeAgentNew_Price").val());
//            var GPSFeiYong = parseFloat($("#FTradeReceivablesChangeAgentNew_GPSFeiYong").val());
//            var YueCuXiaoJinE = parseFloat("-" + $("#FTradeReceivablesChangeAgentNew_YueCuXiaoJinE").val());

//            $("#FTradeReceivablesChangeAgentNew_HeTongJinE").val(Price + GPSFeiYong + YueCuXiaoJinE);

//        })
    })
    function validateCallbackFTradeReceivablesChangeHeTong(form, callback) {

        var $form = $(form);
//        var $oldHeTongHao = "<%=obj.HeTongHao %>";
//        var $newHeTongHao = $("#FTradeReceivablesChangeAgentNew_HeTongHao").val();
        //var $table = $form.find("tbody.ODailyAdd");
        var $newXiaoShouLeiXing = $("#FTradeReceivablesChangeAgentAdd_XiaoShouLeiXing").val();
        if ($newXiaoShouLeiXing == "请选择") {
            alertMsg.warn("请先选择一个 新的收款条款");
            return false;
        }
//        if ($oldHeTongHao == $newHeTongHao) {
//            alertMsg.warn("变更收款条款后，需要更改合同号");
//            $form.find("#FTradeReceivablesChangeAgentNew_HeTongHao").focus();
//            return false;
//        }
        //新增时需要处理 金额是否与合同金额一致
        var $XiaoShouLeiXing = $("#FTradeReceivablesChangeHeTongAdd_XiaoShouLeiXing").val();
        var $HeTongJinE = $("#FTradeReceivablesChangeHeTongNew_HeTongJinE").val();
        var $inputPageJinE = 0;
        $("#FTradeReceivablesChangeHeTongAdd_ShowXXLSPage").find(":text[name='Page_JinE']").each(function () {
            $inputPageJinE = $inputPageJinE + parseFloat($(this).val());
        });
        if (parseFloat($HeTongJinE).toFixed(4) != parseFloat($inputPageJinE).toFixed(4)) {
            alertMsg.warn("合同金额与收款条款[" + $XiaoShouLeiXing + "]相应金额不一致,请检查更改后再提交.");
            return false;
        }

        $("#FTradeReceivablesChangeHeTong_BtnSave").find("button").attr("disabled", "disabled").html("变更中......");
        setTimeout(function () { $("#FTradeReceivablesChangeHeTong_BtnSave").find("button").removeAttr("disabled").html(" 确认变更 "); }, 20000);

        //
        return validateCallback(form, callback);
    }
</script>
<div class="pageContent">
	<form  method="post" class="pageForm required-validate" action="FTradeModel/FTradeReceivablesChangeHeTong.aspx?ajaxmethod=add&FTradeID=<%=FTradeID %>" onsubmit="return validateCallbackFTradeReceivablesChangeHeTong(this, navTabAjaxDone);" >
		<div class="pageFormContent" layoutH="56">
            
            <h2 style=" padding:5px 0px 5px 6px; border-bottom:1px solid #B8D0D6;">合同信息 【<a href="FTradeModel/FTradeReceivablesView.aspx?FTradeID=<%=FTradeID %>" target="navTab" title="查看数据源" rel="FTradeReceivablesView" style=" font-weight:normal!important; color:Red;" >点击</a>】可查看合同的详细信息</h2>
			    
                <p>
				    <label>合 同 号：</label>
				    <input name="HeTongHao" type="text" class="required"  value="<%=obj.HeTongHao %>" />
			    </p>
			    <p>
				    <label>销售时间：</label>
				    <input name="XiaoShouShiJian" class="required " readonly type="text" value="<%=obj.XiaoShouShiJian.ToString("yyyy-MM-dd") %>"  alt=""  />
			    </p>
			    <p>
				    <label>经 销 商：</label>
                    <input name="JingXiaoShang" type="text" value="<%=obj.JingXiaoShang %>" readonly  class="required textInput autocomplete"   autocompletehref="<%=AutoCompleteRequestUrl %>?ajaxmethod=getagentlist" swidth="300"/>
			    </p>
                <p>
				    <label>营业经理：</label>
				    <input name="YingYeJingLi" class="required" type="text"  readonly value="<%=obj.YingYeJingLi %>" alt="请输入营业经理" />
			    </p>
                <div class="divider"></div>
			    <p>
				    <label>型    号：</label>
                    <input name="XingHao" class="" type="text" readonly value="<%=obj.XingHao %>" />
			    </p>
                <p>
				    <label>机    号：</label>
				    <input name="JiHao" class="required" readonly type="text" size="" alt=""  value="<%=obj.JiHao %>" />
			    </p>
                <div class="divider"></div>
			    <p>
				    <label>单    价：</label>
				    <input id="" name="Price" readonly class="required inputFloat" type="text" value="<%=obj.Price %>" size="" alt="" />
                    <span class="unit">元</span>
			    </p>
                <p>
				    <label>GPS费 用：</label>
				    <input id="" name="GPSFeiYong" class="required inputFloat" readonly type="text" value="<%=obj.GPSFeiYong %>" size="" alt="" />
                    <span class="unit">元</span>
			    </p>
                <p>
				    <label>月促销折让金额：</label>
                  
                    <input id="" name="YueCuXiaoJinE" class="required inputFloat" type="text" readonly value="<%=obj.YueCuXiaoJinE %>" size="" alt="" />
                    <span class="unit">元</span>
			    </p>
                   <p>
				        <label>GPS 号：</label>
				        <input name="GPSNum" class="" type="text" value="<%=obj.GPSNum %>" readonly size="" alt="" />
			        </p>
            <p>
				        <label>利息收入：</label>
				        <input  name="InterestIncome" class="required inputFloat" type="text" value="<%=obj.InterestIncome %>" size="" alt="" readonly/>
                        <span class="unit">元</span>
			        </p>  
                <div class="divider"></div>
			    <p>
				    <label>合同金额：</label>
				    <input id="FTradeReceivablesChangeHeTongNew_HeTongJinE" name="HeTongJinE" readonly class="required inputFloat" type="text"   value="<%=obj.HeTongJinE %>"  size="" alt=""/>
                    <span class="unit">元</span>
			    </p>
                 <p>
				        <label>返还利息额：</label>
				        <input  name="FanHuanLiXi" class="inputFloat" type="text" value="<%=obj.FanHuanLiXi %>" size="" alt=""/>
                        <span class="unit">元</span>
			        </p>   
                <p>
				    <label>到期日：</label>
				    <input name="DaoQiRi" class="" type="text" value="<%=obj.DaoQiRi %>" alt="" readonly  />
			    </p>
                <div style="clear:both;"></div>
            
				<label>合同付款条款：</label>
				<textarea name="FuKuanTiaoKuan" cols="80" rows="4"  ><%=obj.FuKuanTiaoKuan%></textarea>
                <div style="clear:both;"></div>
                <p>
			        <label>已收款项：</label>
			        <input name="YiShouKuanXiang" class="" type="text" readonly value="<%=obj.YiShouKuanXiang %>"　readonly />
		        </p>
                <p>
			        <label>未收款项：</label>
			        <input name="WeiShouKuanXiang" class="" type="text" readonly value="<%=obj.WeiShouKuanXiang %>"　readonly />
		        </p>
                <p>
			        <label>逾期款项：</label>
			        <input name="YuQiKuanXiang" class="" type="text" readonly value="<%=obj.YuQiKuanXiang %>"  alt=""/>
		        </p>

                <div style="clear:both;"></div>
               
                <label style=" color:Green; font-weight:bold;">新的合同收款条款：</label>
                <select id="FTradeReceivablesChangeHeTongAdd_XiaoShouLeiXing" name="XiaoShouLeiXing" class="required">
					<%=GetXiaoShouLeiXing(obj.XiaoShouLeiXing)%>
			    </select>
                <div id="FTradeReceivablesChangeHeTong_ShowSummary" style=" line-height:30px; color:Red; font-weight:bold;" >
                       
                </div>
                <div style="clear:both;"></div>
                <div id="FTradeReceivablesChangeHeTongAdd_ShowXXLSPage" style=" border:1px dotted #B8D0D6;  margin:5px 0px; ">
                    <%--显示显示销售对应的配置--%>
                </div>
                <script type="text/javascript">
                    $(document).ready(function () {

                        $("#FTradeReceivablesChangeHeTongAdd_XiaoShouLeiXing").change(function () {
                            changeXiaoShouLeiXingFTradeReceivablesChangeHeTongAdd($(this).val());
                        })
                        function changeXiaoShouLeiXingFTradeReceivablesChangeHeTongAdd(key) {
                            key = encodeURI(key);
                            var url = "FTradeModel/GetPageFTradeSaleTypeConfig.aspx?tag=changehetong&key=" + key
                            $("#FTradeReceivablesChangeHeTongAdd_ShowXXLSPage").loadUrl(url);
                            //
                            url = "FTradeModel/GetPageFTradeSaleTypeConfig.aspx?ajaxmethod=getconfigsummary&key=" + key
                            $("#FTradeReceivablesChangeHeTong_ShowSummary").loadUrl(url);

                        }


                        changeXiaoShouLeiXingFTradeReceivablesChangeHeTongAdd('<%=obj.XiaoShouLeiXing %>');
                    })
                </script>

                <div style="clear:both;margin-bottom: 5px;"></div>   
                
        </div>
		<div class="formBar">
			<ul>
				
				<li ><div id="FTradeReceivablesChangeHeTong_BtnSave" class="buttonActive"><div class="buttonContent"><button type="submit"  >确认变更</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>